@import './mixin';

.btn {
  position: relative;
  display: inline-block;
  font-weight: $btn-font-weight;
  line-height: $btn-line-height;
  color: $body-color;
  white-space: nowrap;
  text-align: center;
  vertical-align: middle;
  background-image: none;
  user-select: none;
  touch-action: manipulation;
  border: $btn-border-width solid transparent;
  box-shadow: $btn-shadow;

  @include button-size(
    $btn-height-base,
    $btn-padding-x-base,
    $btn-font-size,
    $btn-border-radius-base
  );
  cursor: pointer;
  transition: all 0.3s ease-in-out;

  &::before {
    position: absolute;
    top: -1px;
    left: -1px;
    right: -1px;
    bottom: -1px;
    z-index: 1;
    display: none;
    background: $component-background;
    opacity: 0.35;
    border-radius: inherit;
    transition: opacity 0.2s;
    content: '';
    pointer-events: none;
  }

  &:active,
  &:focus {
    outline: 0;
  }

  &:not([disabled]):hover {
    text-decoration: none;
  }

  &:not([disabled]):active {
    text-decoration: none;
    outline: 0;
  }

  @include btn-disabled();

  &.disabled,
  &[disabled] {
    cursor: not-allowed;
    opacity: $btn-disabled-opacity;
    box-shadow: none;

    > * {
      pointer-events: none;
    }
  }

  > i,
  > span {
    display: inline-block;
    pointer-events: none;
  }

  &-loading {
    position: relative;

    &:not([disabled]) {
      pointer-events: none;
    }

    &::before {
      display: block;
    }

    &-icon {
      padding-right: $margin-xs;
    }
  }

  &-block {
    width: 100%;
  }

  &-circle,
  &-circle-outline {
    @include btn-circle();
  }

  &-round {
    @include btn-round();
  }

  &-lg {
    @include button-size(
      $btn-height-lg,
      $btn-padding-y-lg,
      $btn-font-size-lg,
      $btn-border-radius-lg
    );
  }

  &-sm {
    @include button-size(
      $btn-height-sm,
      $btn-padding-y-sm,
      $btn-font-size-sm,
      $btn-border-radius-sm
    );
  }

  &-primary {
    @include button-style($primary, $primary, $white);
  }

  &-default {
    @include button-style($white, $gray-400, $body-color, $white, $primary, $primary);
  }

  &-danger {
    @include button-style($danger, $danger, $white);
  }

  &-dashed {
    @include button-style($white, $gray-400, $body-color, $white, $primary, $primary);
    border-style: dashed;
  }

  &-link {
    font-weight: $font-weight-normal;
    color: $btn-link-color;
    text-decoration: $link-decoration;
    box-shadow: none;

    &:hover {
      color: $btn-link-hover-color;
      text-decoration: $link-hover-decoration;
    }

    &:focus,
    &.focus {
      text-decoration: $link-hover-decoration;
      box-shadow: none;
    }

    &:disabled,
    &.disabled {
      color: $btn-link-disabled-color;
      pointer-events: none;
    }
  }
}
